<?php

	namespace app\timer\behavior;

	use app\admin\model\note\Order;
	use app\admin\model\note\Task;

	class Day{
		public function workteam(){
			$auto = new \addons\workteam\controller\Autotask();
			$auto->index();
		}

		public function facrm(){
			$auto = new \addons\facrm\controller\Autotask();
			$auto->index();
		}

		public function memory(){
			$orderModel = new Order();
			$dayModel = new \app\admin\model\note\Day();
			$taskModel = new Task();
			$date = date('Y-m-d');
			$orders = $orderModel->alias('o')
				->join('note_day d', 'd.uid = o.uid and d.date_text = "'.$date.'"','left')
				->where(['d.id'=>['not null',''],'o.is_memory'=>1,'o.start_time'=>['<=',time()],'o.end_time'=>['>=',time()]])
				->field('o.id,o.uid,d.id as day_id')->select();
			foreach($orders as $order){
				$tasks = $taskModel->where(['day_id'=>$order->day_id,'uid'=>$order->uid])->select();
			}
		}
	}